let Utils = function () {

    //获取url参数
    this.getQueryString = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substring(1).match(reg);
        if (r != null) return decodeURIComponent(r[2]);
        return null;
    }

    this.distance = function (x1, y1, z1, x2, y2, z2) {
        return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2));
    }

}

Utils.prototype.constructor = Utils;

/**
 * 函数防抖
 */
function createDebounce(waitTime) {
    let timeout;

    return (func) => {
        if (timeout) {
            clearTimeout(timeout);
        }

        timeout = setTimeout(() => {
            timeout = undefined;
            func();
        }, waitTime || 500);
    };
}

export { Utils, createDebounce }
